# Author    :Dun_Hz
# Time      :2024/3/18 14:22

# 十进制 -----> 二进制
from Stack import Stack
def divide_by_2(num):
    s = Stack()
    while num>0:
        res = num%2
        s.push(res)
        num = num//2
    res = ''
    while not s.isEmpty():
        res = res+str(s.pop())
    return res

# 十进制 -----> 十六进制
from Stack import Stack
def divide_by_16(num):
    digits = '0123456789ABCDEF'
    s = Stack()
    while num>0:
        res = num%16
        s.push(res)
        num = num//16
    res = ''
    while not s.isEmpty():
        res = res+digits[s.pop()]
    return res

if __name__ =='__main__':
    res = divide_by_2(13)
    print(res)
    res = divide_by_16(13)
    print(res)
